﻿using Efcore_Test.Entities;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Reflection.Emit;
using Volo.Abp.Data;
namespace Efcore_Test.Data
{
    public class MyDbContext : IdentityDbContext<MyUser, IdentityRole<Guid>, Guid>
    {
        public MyDbContext(DbContextOptions<MyDbContext> options)
       : base(options)
        {
        }

        // 你可以定义其他表
        public DbSet<Articlexxxxx22> Articlexxxxx22 { get; set; }

        //public DbSet<Comment> comments { get; set; }

        //public DbSet<User> users { get; set; }

        //public DbSet<Leave> leaves { get; set; }

        //public DbSet<OrgUnit> orgUnits { get; set; }

        //public DbSet<Order> orders { get; set; }

        //public DbSet<Delivery> deliveries { get; set; }

        //public DbSet<Student> students { get; set; }

        //public DbSet<Teacher> teachers { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<Articlexxxxx22>(b =>
            {
                b.HasNoKey(); // 或者 Key+Value 联合主键
            });
            base.OnModelCreating(builder);
            builder.Entity<MyUser>().ToTable("UserMange_Users"); // AspNetUsers → Users
            builder.Entity<IdentityRole<Guid>>().ToTable("UserMange_Roles"); // AspNetRoles → Roles
            builder.Entity<IdentityUserRole<Guid>>().ToTable("UserMange_UserRoles");
            builder.Entity<IdentityUserClaim<Guid>>().ToTable("UserMange_UserClaims");
            builder.Entity<IdentityUserLogin<Guid>>().ToTable("UserMange_UserLogins");
            builder.Entity<IdentityUserToken<Guid>>().ToTable("UserMange_UserTokens");
            builder.Entity<IdentityRoleClaim<Guid>>().ToTable("UserMange_RoleClaims");
            //builder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
